#!/usr/bin/python
# -*- coding: UTF-8 -*-

#! encoding = utf-8

from lib.base import Douyin
from lib.func import reportServer
import sys

def start(device_id, p_name):
    self = Douyin(device_id)
    self.open_douyin_by_packname(p_name)
    not_login = self.check_is_not_login()
    if not_login:
        return reportServer("userinfo", {"device_id":device_id, "p_name":p_name, "login_status": 2})

    self.click_text_and_check("我")
    self.sleep(3)
    name = self.device(resourceId="com.ss.android.ugc.aweme:id/aer").get_text()
    follow = self.device(resourceId="com.ss.android.ugc.aweme:id/afe").get_text()
    fans = self.device(resourceId="com.ss.android.ugc.aweme:id/afg").get_text()
    reportServer("userinfo", {"device_id":device_id, "p_name":p_name, "login_status":1, "login_name":name, "follow":follow, "fans":fans})

if __name__ == "__main__":
    device_id = sys.argv[1]
    p_name = sys.argv[2]
    start(device_id, p_name)